package com.xqboss.web.controller.consumer;

import com.xqboss.apps.domain.consumer.ConsumerTeamGiveRecord;
import com.xqboss.apps.dto.consumer.ConsumerTeamGiveRecordDto;
import com.xqboss.apps.dto.team.ConsumerTeamUpgradeAmplifyDto;
import com.xqboss.apps.service.consumer.ConsumerTeamGainRuleService;
import com.xqboss.apps.service.consumer.ConsumerTeamGiveRecordService;
import com.xqboss.apps.service.consumer.ConsumerTeamUpgradePlanService;
import com.xqboss.apps.vo.team.ConsumerTeamUpgradeAmplifyVo;
import com.xqboss.apps.vo.user.ConsumerTeamGiveRecordVo;
import com.xqboss.common.annotation.RepeatSubmit;
import com.xqboss.common.core.controller.BaseController;
import com.xqboss.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 队伍升级配置(ConsumerTeamUpgradeRule)表控制层
 *
 * @author makejava
 * @since 2023-12-15 14:27:09
 */
@Api(tags = {"队伍升级"})
@RestController
@RequestMapping("/web/team/upgrade")
public class WebConsumerTeamUpgradeController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private ConsumerTeamUpgradePlanService consumerTeamUpgradePlanService;
    @Autowired
    private ConsumerTeamGainRuleService consumerTeamGainRuleService;
    @Autowired
    private ConsumerTeamGiveRecordService consumerTeamGiveRecordService;


    @PreAuthorize("@ss.hasPermi('web:team:upgrade:plan:conf')")
    @ApiOperation("增益-方案")
    @GetMapping("/rule-conf")
    public R<ConsumerTeamUpgradeAmplifyVo> ruleConf() {
        return R.ok(consumerTeamUpgradePlanService.planConf());
    }

    @RepeatSubmit(interval = 1000, justUrl = true)
    @PreAuthorize("@ss.hasPermi('web:team:upgrade:plan:edit')")
    @ApiOperation("编辑")
    @PostMapping("/plan-edit")
    public R<Boolean> planInfo(@Validated @RequestBody ConsumerTeamUpgradeAmplifyDto params) {
        return R.ok(consumerTeamUpgradePlanService.planEdit(params));
    }

    @PreAuthorize("@ss.hasPermi('web:team:upgrade:del-rule')")
    @ApiOperation("删除-增益")
    @PostMapping("/del-rule")
    public R<Boolean> delRule(@RequestBody ConsumerTeamUpgradeAmplifyDto params) {
        return R.ok(consumerTeamGainRuleService.delByIds(params.getDelIds()) > 0);
    }

//    @PreAuthorize("@ss.hasPermi('web:team:upgrade:give:record')")
//    @ApiOperation("转增记录")
//    @GetMapping("/give-record")
//    public R<List<ConsumerTeamGiveRecordVo>> giveRecord(@Validated ConsumerTeamGiveRecordDto dto) {
//        List<ConsumerTeamGiveRecord> consumerTeamGiveRecord = consumerTeamGiveRecordService.giveRecord(dto);
//        List<ConsumerTeamGiveRecordVo> consumerTeamGiveRecordVo = consumerTeamGiveRecordService.giveRecord(consumerTeamGiveRecord);
//        return R.ok(consumerTeamGiveRecordVo, consumerTeamGiveRecord);
//    }
}

